package com.course.controller;

import com.course.component.http.Crp;
import com.course.dto.reqs.RequestRole;
import com.course.masterservice.RoleMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Copyright: Copyright (c)  林中小鸟  All rights reserved.
 * @author: moon
 * @date: 2022/9/20 11:12
 * @Description: **********************
 */
@RestController
@RequestMapping(value = "/x/role")
public class RoleController {
    @Autowired
    private RoleMasterService roleMasterService;

    @GetMapping(value = "list")
    public Crp list(RequestRole requestRole) {
        return Crp.success(roleMasterService.list(requestRole));
    }

    @DeleteMapping(value = "del")
    public Crp del(@RequestBody RequestRole requestRole) {
        return Crp.success(roleMasterService.del(requestRole));
    }

    @PostMapping(value = "edit")
    public Crp edit(@RequestBody RequestRole requestRole) {
        return Crp.success(roleMasterService.update(requestRole));
    }

    //role
    @PostMapping("link")
    public Crp link(@RequestBody RequestRole requestRole) {
        return Crp.success(roleMasterService.linkPermission(requestRole));
    }
}
